package components.blocks;

import java.awt.Color;

import scenes.CollisionablesScene;

import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.appearances.Appearance;
import com.uqbar.vainilla.appearances.Rectangle;
import components.CollisionableComponent;
import components.ball.NormalBall;

public class Block extends CollisionableComponent<CollisionablesScene> {
	
	private int score;
	// lo saca de un cfg o algo
	public static int WIDTH = 40;
	public static int HEIGHT = 20;

	public Block(Appearance ap, double x, double y, int aScore){
		super (Block.WIDTH, Block.HEIGHT, x, y);
		this.setAppearance(ap);
		this.setScore(aScore);
	}
	public Block(Appearance ap, int aScore){
		this (ap, 0, 0, aScore);
		this.setAppearance(ap);
		this.setScore(aScore);
	}


	@Override
	public boolean isSolid() {
		return true;
	}

	@Override
	protected void onCollisionWithSolid(CollisionableComponent gc) {
		
	}

	@Override
	protected void defineCollide(CollisionableComponent gc) {
		gc.collideWithBlock(this);
	}
	
	@Override
	public void collideWithBall(NormalBall ball) {
		this.destroyBlock();
	}


	protected void destroyBlock() {
		this.destroyComponent();
		this.getScene().blockDestroyed(this);
	}


	@Override
	protected void effectiveUpdate(DeltaState deltaState) {
		// TODO Auto-generated method stub
		
	}


	public void setScore(int score) {
		this.score = score;
	}


	public int getScore() {
		return score;
	}



}
